using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;
 

public partial class JobSeekers_skills : System.Web.UI.Page
{
    string connectionString = "";
                     
    protected void Page_Load(object sender, EventArgs e)
    {
        connectionString =
                        WebConfigurationManager.ConnectionStrings[
                        "Database2000"].ConnectionString;
        if (Session.Contents["jsuserid"] == null)
        {
            Response.Redirect("login.aspx");
        }
        else
            if(!IsPostBack)
                EditSkill();
    }
    void EditSkill()
    {
        SqlServerProvider cls = new SqlServerProvider(connectionString);
        
        cls.CommandText = "select * from tblJSSkills" +
        " where UserID=@UserID";
        cls.ParameterCollection = new string[1]{"@UserID"};
        cls.ValueCollection = new string[1] {Session["jsuserid"].ToString()};
        DataTable dataTable =cls.GetDataTable( );
        if(dataTable.Rows.Count >0)
        {
            SkillID.Value = dataTable.Rows[0][0].ToString();
            txtSpeed.Text=dataTable.Rows[0][2].ToString();
            txtSoftware.Text=dataTable.Rows[0][3].ToString();
            rblVNSpeaking.SelectedValue=dataTable.Rows[0][4].ToString();
            rblVNReading.SelectedValue=dataTable.Rows[0][5].ToString();
            rblVNListening.SelectedValue=dataTable.Rows[0][6].ToString();
            rblENSpeaking.SelectedValue=dataTable.Rows[0][7].ToString();
            rblENReading.SelectedValue=dataTable.Rows[0][8].ToString();
            rblENListening.SelectedValue=dataTable.Rows[0][9].ToString();
            txtDescription.Text = dataTable.Rows[0][10].ToString();
        }                   
       
    }
    protected void btnNext_Click(object sender, EventArgs e)
    {
        if (SkillID.Value != "")
            Response.Redirect("resumes.aspx");
        else
            Response.Redirect("resume.aspx");
        
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        SqlServerProvider cls = new SqlServerProvider(connectionString);
        if (!cls.AddNewUpdateSkill(
        ((SkillID.Value!="")?SkillID.Value:"0"), 
        Convert.ToString( Session.Contents["jsuserid"]),
        txtSpeed.Text,
        txtSoftware.Text,
        rblVNSpeaking.SelectedValue,
        rblVNReading.SelectedValue,
        rblVNListening.SelectedValue,
        rblENSpeaking.SelectedValue,
        rblENReading.SelectedValue,
        rblENListening.SelectedValue,
        txtDescription.Text))
            literalError.Text = "Error: " + cls.ErrorMessage;
        else
            if(SkillID.Value!="")
            {
                Session["ResumeStatus"] = "Update";
                Response.Redirect("resumes.aspx");
            }
            else
               {
                    Session["ResumeStatus"] = "New";
                    Response.Redirect("resume.aspx");
               }
    }
}
